<?php


namespace App\Modules\Order\Criterias;


use Flower\Core\Repository\Contracts\RepositoryInterface;
use Flower\Core\Repository\Criterias\BaseCriterias;

class getOrderPointListCriteria extends BaseCriterias
{
    public $params;
    public function __construct($storeId,$userId,$startDate,$endDate)
    {
        $this->params = [
            'store_id' => $storeId,
            'barber_id' =>$userId,
            'start_date' => $startDate,
            'end_date' =>$endDate
        ];
    }

    public function apply($model, RepositoryInterface $repository)
    {
        return $model
        ->select(['id','member_id','finish_time'])
        ->with('member:id,name,face')
        ->whereRaw('store_id in (' . $this->params['store_id'] . ') and is_appoint=1  and barber_id="'.$this->params['barber_id'].'"  and FROM_UNIXTIME(finish_time,\'%Y-%m-%d\') <= "' . $this->params['start_date'] . '" and FROM_UNIXTIME(finish_time,\'%Y-%m-%d\') >="' . $this->params['end_date'] . '"');
    }

}
